/**
 * 猪哥亮开源
 * 作者 猪哥亮
 * 邮箱 1030681978@qq.com
 */
package cn.jnetty.ioc.ann.support;

import cn.jnetty.api.annotation.JScope;
import cn.jnetty.ioc.ann.config.AnnotationWrapper;
import cn.jnetty.ioc.factorys.config.BeanDefinition;
import cn.jnetty.ioc.factorys.support.GenericBeanDefinition;

/**
 * @author 猪哥亮
 * @email 1030681978@qq.com
 * @date 2020/7/6 17:20
 * 描述： 
 *
 */
public class JScopAnnotationWrapper implements AnnotationWrapper {
    private JScope scope;
    public JScopAnnotationWrapper(JScope scope) {
        this.scope = scope;
    }
    @Override
    public void wrapper(BeanDefinition beanDefinition) {
        GenericBeanDefinition definition = (GenericBeanDefinition) beanDefinition;
        switch (scope.value()){
            case "singleton":
                definition.setSingleton(true);
                break;
            case "prototype":
                definition.setPrototype(true);
                break;
            default:
                definition.setSingleton(true);
                break;
        }
    }
}
